//
//  TYWebView.h
//  UnionMedApp
//
//  Created by 谢航宇_WORK on 2021/5/7.
//  Copyright © 2021 唐家钦. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>

typedef enum  : NSUInteger {
    ///网页链接
    TYWebViewLoadTypeURL = 0,
    ///本地文件
    TYWebViewLoadTypeLocalName,
    ///HTML字符串
    TYWebViewLoadTypeHTMLString,
}TYWebViewLoadType;


NS_ASSUME_NONNULL_BEGIN


@protocol TYWebViewDelegate <NSObject>
- (void)webViewTitleDidChange:(WKWebView *)webView;
- (void)webViewDidFinishLoad:(WKWebView *)webView;
- (void)webView:(WKWebView *)webView didTouchImage:(NSString *)imageUrl;
@end


@interface TYWebView : UIView
@property (nonatomic,weak) id <WKNavigationDelegate,WKScriptMessageHandler,WKNavigationDelegate,TYWebViewDelegate,UIWebViewDelegate> delegate;
@property (nonatomic,copy) NSURL *url; 
@property (nonatomic,copy) NSString * urlString;
- (instancetype)initWithUrl:(NSURL *)url;
- (void)loadUrlString:(NSString *)urlString type:(TYWebViewLoadType)type;
@property (nonatomic,retain) WKWebView * webView;
@property (nonatomic,copy) NSString * title;
///添加网页事件监听
- (void)addWebViewObserve:(NSString *)name complete:(void(^)(id obj))complete;
@end

@interface TYWebViewHandler : NSObject 
@property (nonatomic,copy) NSString * name;
@property (nonatomic,copy) void(^complete)(id obj);
- (instancetype)initWithName:(NSString *)name complete:(void(^)(id obj))complete;
@end
NS_ASSUME_NONNULL_END
